import java.util.Scanner;

public class genshi {
    public int[] a;
    public int[] ans;
    public int n=0;
    public static void main(String[] args) {
        genshi gs = new genshi();
        gs.Scan();
        gs.solution();
    }
    public void solution(){
        int times;
        int tempt;
        int tempt2=1;
        for(int i=0;i<n;i++){
            int j=2;
            int flag=0;
            while(true){
                 times = 0;
                 tempt= j;
                while(a[i]%j==0){
                    times++;
                    if(times==1){
                        tempt2 = j;
                    }
                    if(times==3){
                        flag=1;
                        break;
                    }
                    j=j*j;
                }
                if(flag==1){
                    ans[i] = tempt2;
                    flag=0;
                }
                if(j>a[i]){
                    break;
                }
                j= tempt+1;
            }
            if(flag==0){
                ans[i] = 1;
            }
            flag=0;
        }
        for(int i =0;i<n;i++){

                System.out.println(ans[i]);

        }
    }

    public void Scan(){
        Scanner s = new Scanner(System.in);

        if(s.hasNextInt()){
            n = s.nextInt();
        }
        a = new int[n];
        ans = new int[n];
        for(int i=0;i<n;i++){
            if(s.hasNextInt()){
                a[i] = s.nextInt();
            }
        }
    }


}
